<?php
use yii\db\Migration;
use common\helpers\Constants;

class m151208_101629_menu_seed_date extends Migration
{
    public function safeUp()
    {
        $this->insert('{{%menu_category}}', [
            'id' => 'backend',
            'name' => '后台菜单',
            'description' => ''
        ]);
        $this->insert('{{%menu_category}}', [
            'id' => 'frontend',
            'name' => '前台菜单',
            'description' => ''
        ]);
        $this->insert('{{%menu}}', [
            'id' => 1,
            'parent_id' => null,
            'category_id' => 'backend',
            'name' => '工作台',
            'url' => '/site/dashboard',
            'target' => '_self',
            'description' => '',
            'icon' => '',
            'status' => Constants::STATUS_ENABLE,
            'sort' => 0
        ]);
        $this->insert('{{%menu}}', [
            'id' => 2,
            'parent_id' => null,
            'category_id' => 'backend',
            'name' => '内容',
            'url' => '/content/article/index',
            'target' => '_self',
            'description' => '',
            'icon' => '',
            'status' => Constants::STATUS_ENABLE,
            'sort' => 0
        ]);
        $this->insert('{{%menu}}', [
            'id' => 3,
            'parent_id' => null,
            'category_id' => 'backend',
            'name' => '系统',
            'url' => '/system/system-information/index',
            'target' => '_self',
            'description' => '',
            'icon' => '',
            'status' => Constants::STATUS_ENABLE,
            'sort' => 0
        ]);
        $this->insert('{{%menu}}', [
            'id' => 4,
            'parent_id' => null,
            'category_id' => 'backend',
            'name' => '扩展',
            'url' => '/modularity/default/index',
            'target' => '_self',
            'description' => '',
            'icon' => '',
            'status' => Constants::STATUS_ENABLE,
            'sort' => 0
        ]);
    }

    public function safeDown()
    {
        $this->delete('{{%menu_category}}', [
            'id' => 'admin'
        ]);
        
        $this->delete('{{%menu}}', [
            'id' => [
                1,
                2,
                3,
                4
            ]
        ]);
    }
}
